package com.cloud.lan.api;

import com.cloud.lan.api.dto.req.TestModelReq;
import com.cloud.lan.api.dto.resp.TestModelResp;
import com.cloud.lan.entity.base.BaseRequest;
import com.cloud.lan.entity.base.BaseResponse;
import com.cloud.lan.entity.base.PageRequest;
import com.cloud.lan.entity.base.PageResponse;
import com.cloud.lan.entity.base.common.PageResult;
import com.cloud.lan.service.ITestModelService;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import javax.annotation.Resource;

/**
 * 测试
 * @author ErKang
 * @date Created in 2021/12/5 04:24
 * @title TestApi.java
 * Department: Product development
 */
@RestController
@RequestMapping(value = {"/v1/test/api/"}, method = {RequestMethod.GET, RequestMethod.POST}, consumes = {"*/*"}, produces = {"application/json"})
public class TestApi {

    @Resource
    ITestModelService testModelService;

    @RequestMapping("one")
    public BaseResponse<Object> one(@RequestBody BaseRequest<Object> request) {
        return BaseResponse.success(request);
    }

    @RequestMapping("page")
    public PageResponse<Object> page(@RequestBody PageRequest<Object> request) {
        PageResult p = new PageResult();
        p.setCurrentPage(1);
        p.setPageSize(10);
        p.setCount(0L);
        return PageResponse.success(p);
    }

//    @RequestMapping("list")
//    public BaseResponse list(TestModelDO vo) {
//        return foodBannerService.list(vo);
//    }

    @RequestMapping("add")
    public BaseResponse<Object> add(@RequestBody BaseRequest<TestModelReq> request) {
        return testModelService.add(request);
    }

    @RequestMapping("list")
    public PageResponse<List<TestModelResp>> list(@RequestBody PageRequest<TestModelReq> request) {
        return testModelService.list(request);
    }

}
